<?php
class Controller_printreceipt extends Controller
{

/**
 *收货员打印标签
 *
 */
    public function before()
    {
    	try {
    		  ACL::Required('printreceipt');
    	} catch ( HTTP_Exception_403 $e ) {
				Message::error('sorry，你没有权限进这个目录');
    		$this->request->redirect ( URL::base (true) );
    	}
        parent::before();
    }
	//显示要打印收货的标签
	public function Action_skutiaoma()
	{
		
//		echo "<pre>";
//	print_r($_GET);
//		echo "</pre>";
//		exit;
		$this->title='收货打印';
		if(isset($_GET))
		{
			$recieve_invoice_id=$_GET['str'];
			//$id=trim($_GET['id'],',');
			$id=substr($_GET['id'],0,-1);
			$sku=substr($_GET['sku'],0,-1);
			$sku_name=substr($_GET['sku_name'],0,-1);
			$sku_standard=substr($_GET['sku_standard'],0,-1);
			//echo $sku_standard;exit;
			$storage_position=substr($_GET['storage_position'],0,-1);
			$quantity=substr($_GET['quantity'],0,-1);//采购数量
			$arrival_quantity=substr($_GET['arrival_quantity'],0,-1);//到货数量
			$id=explode(',',$id);
			$sku=explode(',',$sku);
			$sku_name=explode(',',$sku_name);
			$storage_position=explode(',',$storage_position);
			$sku_standard=explode(',',$sku_standard);
			$quantity=explode(',',$quantity);
			$arrival_quantity=explode(',',$arrival_quantity);
			$arr=array();
//					echo "<pre>";
//		print_r($sku_standard);
//		echo "</pre>";
//		exit;
			foreach($id as $kk=>$v)
			{
				$arr[$kk]['id']=$v;
				$arr[$kk]['sku']=$sku[$kk];
				$arr[$kk]['sku_name']=$sku_name[$kk];
				$arr[$kk]['sku_standard']=$sku_standard[$kk];
				$arr[$kk]['storage_position']=$storage_position[$kk];
				$arr[$kk]['quantity']=$quantity[$kk];
				$arr[$kk]['arrival_quantity']=$arrival_quantity[$kk];
			}
			//print_r($arr);exit;
		
			$view=View::factory('receipt/skutiaoma');
			$view->arr=	$arr;
			$view->recieve_man=$_GET['recieve_man']	;
			$view->recieve_invoice_id=$recieve_invoice_id;      		
			 $this->response->body($view);
		}
		else 
		{
			$view=View::factory('receipt/receipt');		      		
		     $this->response->body($view);
		}
		
	}
	//显示之前已经到货的标签
	public function action_skubarcode()
	{
//		echo "<pre>";
//		print_r($_GET);
//		echo "</pre>";
		$arr=array();
		if(isset($_GET))
		{
			$userId=	USER::Active_user()->id;
			$user_name=Erpuser::nick_by_id($userId);
			$arr[0]['id']=trim($_GET['id']);
			$arr[0]['sku']=trim($_GET['sku']);
			$arr[0]['sku_name']=trim($_GET['sku_name']);
			$arr[0]['sku_standard']=trim($_GET['sku_standard']);
			$arr[0]['storage_position']=trim($_GET['storage_position']);
			$arr[0]['quantity']=trim($_GET['quantity']);//采购数量
			$arr[0]['arrival_quantity']=trim($_GET['arrival_quantity']);
			$arr[0]['recieve_time']=trim($_GET['recieve_time']);
			$view=View::factory('receipt/skutiaoma');
			$view->recieve_invoice_id=trim($_GET['str']);//收货单号
			$view->recieve_man=	$_GET['recieve_man'];
			$view->set('user_name',$user_name);
			$view->arr=	$arr;
			 $this->response->body($view);
		}
	}
}
